package com.fanshilz.flower2025.apps.admin.sysUser.resp;

import com.mybatisflex.annotation.RelationOneToMany;
import lombok.Data;

import java.sql.Timestamp;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class SysUserTableDetailResp {

    private Long userId;

    private String userUuid;

    private String userMobile;

    private String userEmail;

    private String nickName;

    private String userName;

    private String loginName;

//    private String pwdTxt;
//
//    private String pwdHash;
//
//    private String pwdSalt;

    @RelationOneToMany(selfField = "userId", targetTable = "sys_user_role", targetField = "userId")
    private List<RoleDetailResp> userRoleIds;

    public void setUserRoleIds(List<RoleDetailResp> userRoleIds) {
        this.userRoleIds = userRoleIds;
        setUserRoles(userRoleIds.stream().map(RoleDetailResp::getRoleId).collect(Collectors.toList()));
    }

    private List<Long> userRoles;

    private Integer userStatus;

    private Timestamp createTime;

    private Long createUserId;

    private String createUserName;

    private Long updateUserId;

    private Timestamp updateTime;

    private String updateUserName;

    @Data
    public static class RoleDetailResp {

        private Long roleId;

        private Long userId;

    }

}
